package com.lwj.liwanjia.adapter;

import android.content.Context;
import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.lwj.liwanjia.R;
import com.lwj.liwanjia.bean.MoreLikeBean;
import com.lwj.liwanjia.utils.CircleTransform;
import com.superrecycleview.superlibrary.adapter.BaseViewHolder;
import com.superrecycleview.superlibrary.adapter.SuperBaseAdapter;

import java.util.List;

/**
 * 猜你喜欢更多
 */

public class LikeMoreAdapter extends SuperBaseAdapter<MoreLikeBean.DataBean.CommendityBean> {
    private Context mContext;

    public LikeMoreAdapter(Context context, List<MoreLikeBean.DataBean.CommendityBean> data) {
        super(context, data);
        mContext = context;
    }

    @Override
    protected void convert(BaseViewHolder holder, MoreLikeBean.DataBean.CommendityBean item, int position) {
        holder.setOnClickListener(R.id.image_like, new OnItemChildClickListener());
        Glide.with(mContext).load(item.getGuessLikeImg()).transform(new CircleTransform(mContext)).placeholder(R.mipmap.guess_image_1).into((ImageView) holder.getView(R.id.icon));
        Glide.with(mContext).load(item.getImageUrl()).placeholder(R.mipmap.guess_image).into((ImageView) holder.getView(R.id.like_image));
        holder.setText(R.id.icon_name, item.getGuessLikeDes())
                .setText(R.id.tv_name, item.getCommodityName())
                .setText(R.id.tv_jieshao, item.getCommdityInfo())
                .setText(R.id.tv_price, "￥" + item.getNowPrice());
        if (item.getCollect() == 0) {
            holder.setImageResource(R.id.image_like, R.mipmap.xihuan_weixuanzhong);
        } else if (item.getCollect() == 1) {
            holder.setImageResource(R.id.image_like, R.mipmap.xihuan_xuanzhong);
        }
    }

    @Override
    protected int getItemViewLayoutId(int position, MoreLikeBean.DataBean.CommendityBean item) {
        return R.layout.like_more_item;
    }
}
